package com.xuecheng.basic.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xuecheng.basic.domain.Dictionary;
import com.xuecheng.basic.mappers.DictionaryMapper;
import com.xuecheng.basic.service.DictionaryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xuecheng.commons.model.vo.DictionaryVo;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.commons.utils.BeanHelper;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 数据字典 服务实现类
 * </p>
 *
 * @author itheima
 * @since 2022-07-17
 */
@Service
public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Dictionary> implements DictionaryService {

    //根据code查询数据字典
    @Override
    public ResponseResult findByCode(String code) {
        //条件
        LambdaQueryWrapper<Dictionary> qw=new LambdaQueryWrapper<>();
        qw.eq(Dictionary::getCode,code);
        Dictionary dictionary = this.getOne(qw);
        //返回
        DictionaryVo vo = BeanHelper.copyProperties(dictionary, DictionaryVo.class);
        return ResponseResult.okResult(vo);
    }
}
